
const express = require("express");
const path = require("path");
const axios = require("axios");
const bodyParser = require("body-parser");

let app = express();
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());

app.get("/", (req, res) => {
  res.sendFile(path.join(__dirname, "./views/index.html"));
})

app.get("/getdata", (req, res) => {
  console.log(req.query);
  res.json({
    info: "返回get请求数据",
    status: 1
  })
})

app.post("/postdata", (req, res) => {
  console.log(req.body);
  res.json({
    info: "返回post请求数据",
    status: 1
  })
})

app.delete("/deletedata", (req, res) => {
  console.log(req.query);
  res.json({
    info: "返回delete请求的数据",
    status: 1
  })
})

app.put("/putdata", (req, res) => {
  console.log(req.body);
  res.json({
    info: "返回put请求的数据",
    status: 1
  })
})